package com.czxy.dem01;

public class Test12 {

    public static void main(String[] args) {

        String[][] all = {
                {"张三","37","89","5"},
                {"李四","95","41","79"},
                {"王五","60","84","29"},
                {"赵六","87","46","86"}
        };
        printMathScore(all);
        getCountMathScore(all);
        getAvgMathScore(all);
        getAvgName(all);
        getAvgCount(all);
    }
    public static void getshow01(String[][] all) {
        int countYU = 0;
        int countSHU = 0;
        int countYING = 0;
        for (int i = 0; i < all.length; i++) {

        }

    }
    public static void printMathScore(String[][] all) {
        for (int i = 0; i < all.length; i++) {
            System.out.println(all[i][0]+" "+all[i][2]);
        }
    }
    public static void getCountMathScore(String[][] all) {
        int sum = 0;
        for (int i = 0; i < all.length; i++) {
            sum+=Integer.parseInt(all[i][2]);
        }
        System.out.println("总分"+sum);
    }
    public static void getAvgMathScore(String[][] all) {
        int sum = 0;
        for (int i = 0; i < all.length; i++) {
            sum+=Integer.parseInt(all[i][2]);
        }
        System.out.println("平均分"+(sum/all.length));
    }
    public static void getAvgName(String[][] all) {
        int sum = 0;
        for (int i = 0; i < all.length; i++) {
            sum+=Integer.parseInt(all[i][2]);
        }
        int avg = sum/all.length;
        for (int i = 0; i < all.length; i++) {
            if (Integer.parseInt(all[i][2]) > avg) {
                System.out.println("数学成绩超过平均分的人："+all[i][0]);
            }
        }
    }
    public static void getAvgCount(String[][] all) {
        int sum = 0;
        for (int i = 0; i < all.length; i++) {
            sum+=Integer.parseInt(all[i][2]);
        }
        int avg = sum/all.length;
        int count  = 0;
        for (int i = 0; i < all.length; i++) {
            if (Integer.parseInt(all[i][2]) > avg) {
                count++;
            }
        }
        System.out.println("数学分数超过平均分的人数："+count);
    }
}
